package ms.maplestory.boot.world.field.objects.mob;

import lombok.Getter;
import lombok.Setter;
import ms.maplestory.boot.world.field.objects.FieldObj;
import ms.maplestory.boot.world.field.objects.mob.skill.MobSkill;
import ms.maplestory.boot.util.container.Tuple;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Getter
@Setter
public class Mob extends FieldObj {

    private int firstAttack;
    private int summonType;
    private int category;
    private int link;
    private int hpTagColor;
    private int hpTagBgColor;
    private int rareItemDropLevel;
    private int hpRecovery;
    private int mpRecovery;
    private int mBookID;
    private int chaseSpeed;
    private int explosiveReward;
    private int flySpeed;
    private int fixedDamage;
    private int removeAfter;
    private int point;
    private int coolDamage;
    private int coolDamageProb;
    private int banType = 1;
    private int banMsgType = 1;
    private boolean HPGaugeHide;
    private boolean boss;
    private boolean undead;
    private boolean noRegen;
    private boolean invincible;
    private boolean hideName;
    private boolean hideHP;
    private boolean noFlip;
    private boolean publicReward;
    private boolean ignoreFieldOut;
    private boolean noDoom;
    private boolean knockBack;
    private boolean removeQuest;
    private boolean ban;
    private boolean selfDestruction;
    private boolean escort = false;
    private long revive;
    private double fs;
    private String mobType = "";
    private String elemAttr = "";
    private String banMsg = "";
    private MobStat mobStat;
    private MobTemporaryStat temporaryStat;

    private List<Tuple<Integer, String>> banMap = new ArrayList<>();
    private Set<Integer> revives = new HashSet<>();
    private List<MobSkill> skills = new ArrayList<>();
    private Set<Integer> quests = new HashSet<>();

    public Mob(int id) {
        super(id);
        mobStat = new MobStat();
        temporaryStat = new MobTemporaryStat(this);
    }

    public Mob deepCopy() {
        Mob copy = new Mob(getId());
        copy.setObjectId(getObjectId());
        copy.setType(getType());
        copy.setId(getId());
        copy.setX(getX());
        copy.setY(getY());
        copy.setMobTime(getMobTime());
        copy.setHide(isHide());
        copy.setFh(getFh());
        copy.setCy(getCy());
        copy.setRx0(getRx0());
        copy.setRx1(getRx1());
//        if (getTemporaryStat() != null) {
//            copy.setTemporaryStat(getTemporaryStat().deepCopy());
//        }
        copy.setFirstAttack(getFirstAttack());
        copy.setSummonType(getSummonType());
        copy.setCategory(getCategory());
        copy.setMobType(getMobType());
        copy.setLink(getLink());
        copy.setFs(getFs());
        copy.setElemAttr(getElemAttr());
        copy.setHpTagColor(getHpTagColor());
        copy.setHpTagBgColor(getHpTagBgColor());
        copy.setHPGaugeHide(isHPGaugeHide());
        copy.setRareItemDropLevel(getRareItemDropLevel());
        copy.setBoss(isBoss());
        copy.setHpRecovery(getHpRecovery());
        copy.setMpRecovery(getMpRecovery());
        copy.setUndead(isUndead());
        copy.setMBookID(getMBookID());
        copy.setNoRegen(isNoRegen());
        copy.setChaseSpeed(getChaseSpeed());
        copy.setExplosiveReward(getExplosiveReward());
        copy.setFlySpeed(getFlySpeed());
        copy.setInvincible(isInvincible());
        copy.setHideName(isHideName());
        copy.setHideHP(isHideHP());
        copy.setNoFlip(isNoFlip());
        copy.setPublicReward(isPublicReward());
        copy.setIgnoreFieldOut(isIgnoreFieldOut());
        copy.setFixedDamage(getFixedDamage());
        copy.setRemoveAfter(getRemoveAfter());
        copy.setNoDoom(isNoDoom());
        copy.setPoint(getPoint());
        copy.setRemoveQuest(isRemoveQuest());
        copy.setCoolDamageProb(getCoolDamageProb());
        copy.setCoolDamage(getCoolDamage());
        copy.setBan(isBan());
        copy.setBanType(getBanType());
        copy.setBanMsgType(getBanMsgType());
        copy.setBanMsg(getBanMsg());
        copy.setBanMap(getBanMap());
        copy.setRevive(getRevive());
        for (MobSkill ms : getSkills()) {
            copy.addSkill(ms);
        }
        for (int rev : getRevives()) {
            copy.addRevive(rev);
        }
        for (int i : getQuests()) {
            copy.addQuest(i);
        }
        return copy;
    }

    public void addBanMap(int fieldID, String portal) {
        banMap.add(new Tuple<>(fieldID, portal));
    }

    public void addRevive(int revive) {
        revives.add(revive);
    }

    public void addSkill(MobSkill skill) {
        skills.add(skill);
    }

    public void addQuest(int questID) {
        quests.add(questID);
    }

    @Override
    public String toString() {
        return String.format("ID: %d, ObjectID: %d, Position:" + getPosition(), getId(), getObjectId());
    }
}
